#include "CSetWaypointNextCommand.h"
#include "CUserInterface.h"
#include "CLevelEditor.h"

extern CGlobals* g;
extern CUserInterface* ui;
extern CLevelEditor* editor;

CSetWaypointNextCommand::CSetWaypointNextCommand (int id, int newValue)
{
	m_id = id;
	m_oldValue = editor->getSceneObjectFromID(id)->m_UserData->getAttributeAsInt("^Next");
	m_newValue = newValue;
	setDescription(stringw(L"change ^Next"));
}

void CSetWaypointNextCommand::redo ()
{
	CSceneObject* obj = editor->getSceneObjectFromID(m_id);
	obj->m_UserData->setAttribute("^Next", m_newValue);
	obj->m_Next = m_newValue;
}

void CSetWaypointNextCommand::undo ()
{
	CSceneObject* obj = editor->getSceneObjectFromID(m_id);
	obj->m_UserData->setAttribute("^Next", m_oldValue);
	obj->m_Next = m_oldValue;
}
